<?php
/*
  $Id: specials.php,v 1.49 2003/06/09 22:35:33 hpdl Exp $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/

  require('includes/application_top.php');

  require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_SPECIALS);

  $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_SPECIALS));
  
  require(DIR_WS_INCLUDES . 'template_top.php');
  
?>
<?php

  //CGDiscountSpecials start
  if (!isset($customer_id)) $customer_id = 0;
  $customer_group = tep_get_customers_groups_id();
  $specials_query_raw = "select DISTINCT p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_SPECIALS . " s where p.products_status = '1' and s.products_id = p.products_id and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and s.status = '1' and ((s.customers_id = '" . $customer_id . "' and s.customers_groups_id = '0') or (s.customers_id = '0' and s.customers_groups_id = '" . $customer_group . "') or (s.customers_id = '0' and s.customers_groups_id = '0')) order by s.specials_date_added DESC";
  //CGDiscountSpecials end
  
  $specials_split = new splitPageResults($specials_query_raw, MAX_DISPLAY_SPECIAL_PRODUCTS);
  
?>
<!--middle area start-->
<div class="middle-area">
  <div class="innermidbox fl">
    <div class="innermidbox-top"></div>
    <div class="innermidbox-mid">
      <div class="pdt5 pdl20 pdr20 pdb5 minheight527px">
        <div class="breadcrumbs">
          <?= $breadcrumb->trail(); ?>
        </div>
        <div class="spacer10"></div>
        <div class="">
          <h1 class="pagetitle"><?php echo $catname; ?></h1>
          <div class="hline"></div>
          <div class="spacer3"></div>
          <!--left panel start-->
          <?php include('includes/template_left.php'); ?>
          <!--left panel end-->
          <!--right panel start-->
          <div class="rightpanel mgl15 fl">
            <?php
						if($specials_split->number_of_rows > 0)
						{
                    ?>
            <?php
                      if (($specials_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3'))) {
                    ?>
            <div class="pagingbox">
              <div class="pdl10 pdt5 pdb5 pdr10">
                <div class="fl"><?php echo $specials_split->display_count(TEXT_DISPLAY_NUMBER_OF_SPECIALS); ?></div>
                <div class="fr">
                  <div class="paging "> <?php echo $specials_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?> </div>
                </div>
                <div class="clear"></div>
              </div>
            </div>
            <!--paging end-->
            <div class="spacer10"></div>
            <?php
                      }
                    ?>
            <?php
    $rows = 0;
    $specials_query = tep_db_query($specials_split->sql_query);
    while($specials = tep_db_fetch_array($specials_query)) 
	{
      $rows++;
	  $specials['specials_new_products_price'] = tep_get_products_special_price($specials['products_id']);
	  
	  $listing_price = '<s>' .  $currencies->display_price($specials['products_price'], tep_get_tax_rate($specials['products_tax_class_id'])) . '</s>&nbsp;&nbsp;<span class="productSpecialPrice">' . $currencies->display_price_nodiscount($specials['specials_new_products_price'], tep_get_tax_rate($specials['products_tax_class_id'])) . '</span>&nbsp;';
	  
	  
?>
            <?php
	  if(($rows+2)%3==0)
	  {
?>
            <div class="productmainbox fl">
              <?php
	  }
	  else
	  {
?>
              <div class="productmainbox fl mgl14">
                <?php		  
	  }
?>
                <div class="pdl5 pdr5 pdt5 pdb5">
                  <div class="productimgbg mgl1">
                    <table width="100%" height="100%">
                      <tr>
                        <td align="center" valign="middle"><a href="<?=tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $specials['products_id'])?>" title="<?=$specials['products_name']?>" >
                          <?=tep_image(DIR_WS_IMAGES . $specials['products_image'], $specials['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT)?>
                          </a></td>
                      </tr>
                    </table>
                  </div>
                  <div class="spacer5"></div>
                  <div class="pdl5 pdr5">
                    <h3 class="listproductname"><a href="<?=tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $specials['products_id'])?>" title="<?=$specials['products_name']?>" >
                      <?=$specials['products_name']?>
                      </a></h3>
                    <div class="spacer5"></div>
                    <div class="spacer5"></div>
                    <a class="readmorered fl" href="<?=tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $specials['products_id'])?>" title="<?=$specials['products_name']?>">Read More</a>
                    <div class="fr listproductprice">
                      <?php /* $currencies->display_price($specials['specials_new_products_price'], tep_get_tax_rate($specials['products_tax_class_id'])); */?>
                      <?=$listing_price?>
                    </div>
                    <div class="spacer5"></div>
                    <a class="listaddtocartbtn" href="<?=tep_href_link(FILENAME_PRODUCTS_NEW, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $specials['products_id'])?>"></a> </div>
                </div>
              </div>
              <?php
			
            if($rows%3==0)
			{
        ?>
              <div class="spacer14"></div>
              <?php
            }
    }
?>
              <div class="spacer10"></div>
              <?php
  if (($specials_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3'))) {
?>
              <div class="pagingbox">
                <div class="pdl10 pdt5 pdb5 pdr10">
                  <div class="fl"><?php echo $specials_split->display_count(TEXT_DISPLAY_NUMBER_OF_SPECIALS); ?></div>
                  <div class="fr">
                    <div class="paging "> <?php echo $specials_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?> </div>
                  </div>
                  <div class="clear"></div>
                </div>
              </div>
              <!--paging end-->
              <div class="spacer10"></div>
              <?php
 	}
}
else
{
?>
              No Special products available right now, check it later.
              <?php
}
?>
              <!--listing end-->
            </div>
            <!--right panel end-->
            <div class="spacer10"></div>
          </div>
        </div>
      </div>
      <div class="innermidbox-bottom"></div>
    </div>
  </div>
  <!--middle area end-->
  <div class="spacer25"></div>
</div>
<?php
require(DIR_WS_INCLUDES . 'template_bottom.php');
require(DIR_WS_INCLUDES . 'application_bottom.php');
?>